package com.tencent.sr.iris.activity.restapi.tools;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * @author xiaojun
 */
@Data
@Slf4j
class UpdateListener extends AnalysisEventListener<ExcelData> {

    /**
     * 每隔5条存储数据库，然后清理list，方便内存回收
     */
    private static final int BATCH_COUNT = 500;

    List<String> list = new ArrayList<>();


    public UpdateListener(List<String> list) {
        this.list = list;
    }

    public UpdateListener() {
    }

    @Override
    public void invoke(ExcelData demoData, AnalysisContext analysisContext) {
        list.add(demoData.getUid());
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        log.info("doAfterAllAnalysed success");
    }
}